package org.example.reemploymentsys.repository;

import org.example.reemploymentsys.entity.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface StudentRe extends JpaRepository<Student, Long> , JpaSpecificationExecutor<Student> {
    @Query("SELECT s FROM Student s WHERE s.organization.id = ?1")
    List<Student> findAllByOrganizationId(String organizationId);

    @Query("SELECT s FROM Student s WHERE s.organization.id = ?1 AND s.name LIKE %?2% OR s.email LIKE %?2% OR s.phone LIKE %?2%")
    List<Student> findAllByOrganizationIdAndNameContaining(String organizationId, String searchText);

    Student findByName(String name);
}
